home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: HELP!!!! --very important!!--
- Date: 22 Mar 1996 22:17:47 GMT
- Organization: OpenVision
- Message-ID: <4iv8ub$95t@spanky.pls.ov.com>
- References: <1996Mar21.000242.138161@forest>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article 138161@forest, groy@forest.drew.edu (I can't think of a nickname) writes:
- >Please Help....
- >I need to get this program working... the function set_diff is supposed to
- >find the differences between the two arrays (a[] and b[]) and put the
- >differences(if any) in array c[]....
- >
- >int set_diff(int a[], int b[], int c[], int max) {
- > int *first = a;
- > int *second = b;
- > int *third = c;
-
- The above three pointers are pointers to *copies* of the input arrays.
- None of the original arrays are affected in any way. If that was not
- your intent, then you need to reformulate your input list to be
- pointers to the arrays, and to adjust your function code accordingly.
-
- Fletcher.Glenn@ov.com
-
-
- > int *endfirst = first + max;
- > int *endsecond = second + max;
- > int count=0;
- > /*first compare each value of a to b and note the differences*/
- >
- > for(first = a,second = b; first< endfirst, second<endsecond;
- > first++,second++){
- > if (*first == *second)
- > count =1;
- >
- > if (count != 1){
- > *third = *first;
- > third++; } count =0;
- > } /* end of for(first ... */
- >return count;
- >} /*end of set_diff */
- >int main () {
- > int a[MAX], b[MAX], c[MAX * 2]; /*the three arrays */
- > int count;
- > int decide;
- >
- > printf("Enter %i integers \n",MAX);
- >
- > for (count = 0; count < MAX; count++)
- > scanf("%i", &a[count]);
- > printf("Enter %i more integers \n",MAX);
- > for (count =0; count < MAX; count++)
- > scanf("%i", &b[count]);
- > decide =set_diff(a, b, c, MAX);
- > /* now print the three arrays */
- > printf("array a\n");
- > for(count = 0; count < MAX; count++)
- > printf("%2i ", a[count]);
- > printf("\narray b\n");
- > for(count = 0; count < MAX; count++)
- > printf("%2i ", b[count]);
- > if (decide != 1) {
- > printf("\ndifference\n");
- > for(count = 0; count < (MAX * 2); count++)
- > printf("%2i ", c[count]); }
- > printf("\n");
- >} /*end of main*/
- >
- >
- >
- >
- >
- >Thankyou for any help.. please hurry I am running out of time...
- >
- >
- >
- >Ps.. there are probbly two more programs on the way...
- >Greg Roy
- >Groy@drew.edu
- >
- >
-
-
-
-
-
-